﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebSite.Models.BaseModel>" %>
<%@ Import Namespace="WebSite.Models" %>
<%@ Import Namespace="WebSite.App_Code" %>
<%@ Import Namespace="WebSite.App_Data" %>

    <link rel="stylesheet" href="../../Scripts/jquery-treeview/jquery.treeview.css" />
	
	<%--<script type="text/javascript" src="../../Scripts/jquery-ui/js/jquery-1.9.1.js"></script>--%>
	<%--<script type="text/javascript" src="../../Scripts/jquery-treeview/lib/jquery.cookie.js"></script>--%>
    <script type="text/javascript" src="../../Scripts/jquery-treeview/jquery.treeview.js"></script>
	

<script type="text/javascript">

//    $(function () {
//        $("#tree").treeview()

//        //$("#tree").treeview({
//            //collapsed: true,
//            //animated: "fast",
//            //control: "#sidetreecontrol",
//            //prerendered: true
//            //persist: "location"
//        //});
//    })

	function EC_(sender) {
		EC( $( $("a", $(sender).next())));
	}

    function EC(sender) {
        var Li = $(sender).parents("li:eq(0)");
        var Img = $("div:eq(0)", Li);
        var Ul = $(sender).parents("span:eq(0)").next("ul:eq(0)");

        if (Li.attr("class") == "expandable lastExpandable") {
            Li.attr("class", "collapsable lastCollapsable");
            Img.attr("class", "hitarea collapsable-hitarea lastCollapsable-hitarea");
            Ul.show();
        }
        else if (Li.attr("class") == "expandable") {
            Li.attr("class", "collapsable");
            Img.attr("class", "hitarea collapsable-hitarea");
            Ul.show();
        }
        else if (Li.attr("class") == "collapsable lastCollapsable") {
            Li.attr("class", "expandable lastExpandable");
            Img.attr("class", "hitarea expandable-hitarea lastCollapsable-hitarea");
            Ul.hide();
        }
        else if (Li.attr("class") == "collapsable") {
            Li.attr("class", "expandable");
            Img.attr("class", "hitarea expandable-hitarea");
            Ul.hide();
        }
    }
		
</script>

<style type="text/css">

.parent { color:Black; text-decoration:none; }
.parent:hover { color: red; }

.nolink
{
    text-decoration:none;
    color:Black;
    font-size:10pt;
    cursor:default;
}

.nolink:hover
{
    color:Black;
}


.pagelink
{
    text-decoration:none;
    color:Blue;
    font-size:10pt;
    cursor:pointer;
}

.selectlink
{
    font-weight:bold;
}

.pagelink:hover
{
    color:Red;
}

.homelink a
{
    font-weight:bolder; 
    color:Black; 
    text-decoration:none;
    font-size:10pt;
}

</style>

<% 
    
   UserItem U = new UserItem();

   if (Session["Global.User"] != null) { U = (UserItem)Session["Global.User"]; }

   MenuViewItem Menu = new MenuViewItem(U.PageList,
	   String.Format("/{0}/{1}{2}", Page.RouteData.Values["controller"], Page.RouteData.Values["action"]
	   , Page.RouteData.Values.ContainsKey("id") ? "/" + Page.RouteData.Values["id"] : ""));
      
%>
<div id="main">
    <div id="sidetree">
        <div class="treeheader">&nbsp;</div>
        <span class="homelink"><%=Html.ActionLink("首页","Index","Home") %></span>        
        <ul class="filetree treeview" id="tree">
        <% foreach (MenuLv1 L1 in Menu.M) { %>
            <%if (L1.Select) { %>
                <% if (L1.Last) { %>
                    <li class="collapsable lastCollapsable">
                    <div class="hitarea collapsable-hitarea lastCollapsable-hitarea" onclick="EC_(this)"></div><% } %>
                <% else { %>
                    <li class="collapsable">
                    <div class="hitarea collapsable-hitarea" onclick="EC_(this)"></div><% } %>
            <% } else { %>            
                <% if (L1.Last) { %>
                    <li class="expandable lastExpandable">
                    <div class="hitarea expandable-hitarea lastExpandable-hitarea" onclick="EC_(this)"></div><% } %>
                <% else { %>
                    <li class="expandable">
                    <div class="hitarea expandable-hitarea" onclick="EC_(this)"></div><% } %>
            <% } %>
                <span class="folder">&nbsp;<a href="#" class="parent" onclick="EC(this)"><%=L1.P.PageTitle %></a></span>
                <% if (L1.C.Count > 0) { %>
                <ul <%if (!L1.Select) { %><%="style=\"display: none;\"" %><% } %> >
                <% foreach (MenuLv2 L2 in L1.C) { %>
                    <%if (L2.Select) { %>
                        <% if (L2.Last) { %>
                            <li class="collapsable lastCollapsable">
                            <div class="hitarea collapsable-hitarea lastCollapsable-hitarea" onclick="EC_(this)"></div><% } %>
                        <% else { %>
                            <li class="collapsable">
                            <div class="hitarea collapsable-hitarea" onclick="EC_(this)"></div><% } %>
                    <% } else { %>
                        <% if (L2.Last) { %>
                            <li class="expandable lastExpandable">
                            <div class="hitarea expandable-hitarea lastExpandable-hitarea" onclick="EC_(this)"></div><% } %>
                        <% else { %>
                            <li class="expandable">
                            <div class="hitarea expandable-hitarea" onclick="EC_(this)"></div><% } %>
                    <% } %>
                    <span class="folder">&nbsp;<a href="#" class="parent" onclick="EC(this)">&nbsp;<%=L2.P.PageTitle%></a></span>
                    <% if (L2.C.Count > 0) { %>
                    <ul <%if (!L2.Select) { %><%="style=\"display: none;\"" %><% } %> >
                    <% foreach (MenuLv3 L3 in L2.C) { %>   
                        <% if (L3.Last) { %><li class="last"><% } %>
                        <% else { %><li><% } %>
                            <span class="file">&nbsp;
                            <%if (String.IsNullOrEmpty(L3.P.PageUrl)) { %>
                                <%=String.Format("<a class='{2}'>{0}</a>", L3.P.PageTitle, L3.P.PageUrl, "nolink") %>
                            <% } else { %>
                                <% if (L3.Select) { %>
                                    <%=String.Format("<a href='{1}' class='{2}'>{0}</a>", L3.P.PageTitle, L3.P.PageUrl, "pagelink selectlink") %>
                                <% } else { %>
                                    <%=String.Format("<a href='{1}' class='{2}'>{0}</a>", L3.P.PageTitle, L3.P.PageUrl, "pagelink") %>
                                <% } %>
                            <% } %>
                            </span>
                        </li>
                    <% } %>
                    </ul>
                    <% } %>
                <% } %>
                </ul>
                <% } %>
            </li>
        <% } %>
    </div>
</div>

